# -*- coding:utf-8 -*-
def add_space(s,num_space):
	"""添加空格"""
	writes = num_space * "*"
	return writes + writes.join(s.splitlines(True))

def del_space(s,num_space):
	"""删除空格"""
	if num_space > min(get_space(s)):
		raise ValueError,'行最小空格数小于删除空格数'
	return '\n'.join(line[num_space:] for line in s.splitlines())

def get_space(s):
	"""获取每行左边的空格数"""
	return [len(line)-len(line.lstrip()) for line in s.splitlines()] 

if __name__ == "__main__":
	s = """ test1
	test2
		test3"""
	print get_space(s)
	#print add_space(s,4)
	print del_space(s,1)
